package com.demo.udp;import java.net.DatagramPacket;import java.net.DatagramSocket;import java.net.InetAddress;import java.net.SocketException;import java.util.Scanner;public class TestDemo {    public static void main(String[] args) throws Exception {        DatagramSocket socket = new DatagramSocket(8866);        while (true) {            byte[] bs = new byte[1024];            DatagramPacket dp = new DatagramPacket(bs, bs.length);            socket.receive(dp);            int len = dp.getLength();            String str = new String(dp.getData(), 0, len);            System.out.println(dp.getAddress()+":"+str);        }    }}